import { getSearchData } from "../../api"

const state = {
  searchList: {},
}
const getters = {
  trademarkList(state) {
    return state.searchList.trademarkList
  },
  attrsList(state) {
    return state.searchList.attrsList
  },
  goodsList(state) {
    return state.searchList.goodsList
  },
  pragationObj(state) {
    const { pageNo, pageSize, total, totalPages } = state.searchList
    const obj = {
      pageNo,
      pageSize,
      total,
      totalPages,
    }
    return obj
  },
}
const actions = {
  async getSearchData({ commit }, option) {
    const result = await getSearchData(option)
    commit("SET_SEARCH_DATA", result.data)
  },
}
const mutations = {
  SET_SEARCH_DATA(state, data) {
    state.searchList = data
  },
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations,
}
